<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('账单统计列表')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>年月：</label>
                            <input name="month" id="month" type='text' class="input-sm" placeholder="请选择年月"
                                   readonly="readonly"/>
                        </li>
                        <li>
                            <label>账本：</label>
                            <select class="form-control" data-placeholder="请选择账本" id="accountId" name="accountId"
                                    th:width="800px"
                                    required>
                                <option value="">请选择账本</option>
                                <option th:each="account:${accountList}"
                                        th:value="${account.id}"
                                        th:text="${account.accountName}"

                                ></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--                        <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="account:bill:add">-->
            <!--                            <i class="fa fa-plus"></i> 添加-->
            <!--                        </a>-->
            <!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="account:bill:edit">-->
            <!--                <i class="fa fa-edit"></i> 修改-->
            <!--            </a>-->
            <!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="account:bill:remove">-->
            <!--                <i class="fa fa-remove"></i> 删除-->
            <!--            </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="account:bill:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var countFlag = [[${@permission.hasPermi('account:bill:count')}]];
    var removeFlag = [[${@permission.hasPermi('account:bill:remove')}]];
    var prefix = ctx + "account/bill";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            selectUrl: prefix + "/bullCount/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            sortName: "month",
            sortOrder: "desc",
            modalName: "账单统计",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'month',
                    title: '月份',
                    sortable: true,
                },
                {
                    field: 'pay',
                    title: '支出',
                    formatter: function (value, item, index) {
                        return value.toLocaleString('zh', {style: 'currency', currency: 'cny'});
                    }
                },
                {
                    field: 'income',
                    title: '收入',
                    formatter: function (value, item, index) {
                        return value.toLocaleString('zh', {style: 'currency', currency: 'CNY'});
                    }
                },
                {
                    field: 'balance',
                    title: '结余',
                    formatter: function (value, item, index) {
                        return value.toLocaleString('zh', {style: 'currency', currency: 'CNY'});
                    }

                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + countFlag + '" href="javascript:void(0)" onclick="$.operate.selectTab(\'' + row.month + '\')"><i class="fa fa-money"></i>更多详情</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //选择年的
    $('#month').datetimepicker({
        format: 'yyyy',
        weekStart: 1,
        autoclose: true,
        startView: 4,
        minView: 4,
        forceParse: false,
        initialDate: new Date(),	//初始化日期.默认new Date()当前日期
        language: 'zh-CN'
    })
</script>
</body>
</html>
